<template>
    <div style="height:450px; width: 100%; margin-left: 15%; " ref="chart">
        
    </div>
</template>

<script>
export default {
    name:'ScoreChart',
    props:{
        Xdata:{
            type:Array,
            default:[]
        },
        Ydata:{
            type:Array,
            default:[]
        }
    },
    data(){
        return{
            chart:null
        }
    },
    mounted(){
        this.chart = this.$echarts.init(this.$refs.chart);
        if(this.Xdata){
            this.initChart();
        }
    },
    methods:{
        initChart(){
            this.chart.setOption(
                this.option.option
            );
        }
    },
    computed:{
        option(){
            return{
                option:{
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                        type: 'shadow'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                        type: 'category',
                        data: this.Xdata,
                        axisTick: {
                            alignWithLabel: true
                        },
                        axisLabel:{
                            show: true,
                            interval: 0
                        }
                        }
                    ],
                    yAxis: [
                        {
                        type: 'value'
                        }
                    ],
                    series: [
                        {
                        name: 'score',
                        type: 'bar',
                        barWidth: '30%',
                        data: this.Ydata
                        }
                    ]
                    }
            }
        }
    }
}
</script>

<style>

</style>